<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<script>
	var ctx = "${ctx}";
</script>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
<meta http-equiv="expires" content="Wed, 26 Feb 209908:21:57 GMT">
<title>发布红包</title>

<link href="${ctx}/static/css/bootstrap.min.css?v=${static_version}"
	rel="stylesheet" />
<link href="${ctx}/static/css/font-awesome.min.css" rel="stylesheet" />
<link href="${ctx}/static/css/animate.min.css?v=${static_version}"
	rel="stylesheet" />
<link href="${ctx}/static/css/style.min.css?v=${static_version}"
	rel="stylesheet" />
<link href="${ctx}/static/css/common.css?v=${static_version}"
	rel="stylesheet" />
<link href="//at.alicdn.com/t/font_zwgrtnv3xdtv5cdi.css"
	rel="stylesheet">

<!-- 插件样式  -->
<link
	href="${ctx}/static/css/plugins/webuploader/webuploader.css?v=${static_version}/"
	rel="stylesheet">
<link href="${ctx}/static/css/plugins/datapicker/datepicker3.css"
	rel="stylesheet">
<link href="${ctx}/static/plugins/region/css/city-picker.css"
	rel="stylesheet" type="text/css" />
<link href="${ctx}/static/plugins/region/css/main.css" rel="stylesheet"
	type="text/css" />

</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content  animated fadeInRight">
		<div class="ibox float-e-margins">

			<!-- 发布喊个红包 -->
			<div class="ibox-title">
				<h5>
					<c:if test="${type=='1'}">全品红包</c:if>
					<c:if test="${type=='2'}">推荐红包</c:if>
					<c:if test="${type=='3'}">喊个红包</c:if>
					<small></small>
				</h5>
			</div>

			<form class="form form-horizontal" id="table_form">

				<div class="ibox-content">

					<input type="hidden" name="id" id="id" value="${bonus.id}">
					<input type="hidden" name="position_id" id="position_id"
						value="${position_id}">

					<div class="form-group">
						<label class="col-sm-2 control-label">投放类型</label>
						<div class="col-sm-10">
							<div class="col-sm-3 m-l-n">
								<select name="resource_type" id="resource_type"
									<c:if test="${!empty bonus}">disabled="disabled"</c:if>
									class="form-control" onchange="changeType(this.value)">
									<option value="-1" data_price="">----选择类型----</option>
									<option value="0"
										<c:if test="${bonus.advert.resource_type==0}"> selected="selected"</c:if>
										data_price="0.3">图片</option>
									<option value="1"
										<c:if test="${bonus.advert.resource_type==1}"> selected="selected"</c:if>
										data_price="0.6">视频</option>
								</select>
							</div>
						</div>
					</div>

					<c:if test="${type=='3'}">
						<div class="form-group">
							<label class="col-sm-2 control-label">喊红包关键字</label>
							<div class="col-sm-8">
								<div id="keywordsidv">
									<c:choose>
										<c:when test="${!empty keywords}">
											<c:forEach items="${keywords}" var="keyword">
												<input type="text" class="form-control input-keyword"
													value="${keyword}" name="keyword" placeholder=" ">
											</c:forEach>
										</c:when>
										<c:otherwise>
											<input type="text" class="form-control input-keyword"
												value="" name="keyword" placeholder=" ">
										</c:otherwise>
									</c:choose>
								</div>
								&nbsp;&nbsp;&nbsp;&nbsp;
								<button onclick="addkeyword()" class="btn btn-primary "
									type="button">添加</button>
							</div>
						</div>
					</c:if>

					<div class="form-group">
						<label class="col-sm-2 control-label">投放区域</label>
						<div class="col-sm-10">
							<div class="col-sm-3 m-l-n">
								<select name="isarea" id="isarea" class="form-control"
									onchange="changeAreaType(this.value)">
									<option value="1"
										<c:choose><c:when test="${!empty regions and !empty bonus}"></c:when><c:otherwise> selected="selected"</c:otherwise></c:choose>>地区</option>
									<option
										<c:if test="${empty regions and !empty bonus}"> selected="selected"</c:if>
										value="0">全国</option>
								</select>
							</div>
						</div>
					</div>

					<div id="regiondiv" class="mb-10">
						<c:choose>
							<c:when test="${empty regions}">
								<div class="row c1">
									<label class="col-sm-2 control-label">投放地区</label>
									<div class="col-sm-4">
										<input id="city-picker" class="form-control" readonly
											name="regioninfo" type="text" value=""
											data-toggle="city-picker">
									</div>
									<div class="col-sm-1">
										<button onclick="addregion()" class="btn btn-primary radius"
											type="button">添加</button>
									</div>
								</div>
							</c:when>
							<c:otherwise>
								<c:forEach items="${regions}" var="region" varStatus="status">
									<div class="row c1">
										<label class="col-sm-2"></label>
										<div class="col-sm-4">
											<input id="city-picker" class="form-control" readonly
												name="regioninfo" type="text" value="${region}"
												data-toggle="city-picker">
										</div>
										<div class="col-sm-1">
											<c:if test="${status.count==1}">
												<button onclick="addregion()" class="btn btn-primary radius"
													type="button">添加</button>
											</c:if>
											<c:if test="${status.count!=1}">
												<button onclick="delregion(this)"
													class="btn btn-danger radius" type="button">删除</button>
											</c:if>
										</div>
									</div>
								</c:forEach>
							</c:otherwise>
						</c:choose>
					</div>

					<div class="form-group mt-10" id="range"
						<c:choose><c:when test="${empty regions or fn:length(regions)==1}"> style="display: block;"</c:when><c:otherwise>style="display: none;"</c:otherwise></c:choose>>
						<label class="col-sm-2 control-label">投放范围</label>
						<div class="col-sm-8">
							<div class="form-group">
								<label class="col-sm-1 control-label">定位</label>
								<div class="col-sm-2">
									<input type="text" class="form-control"
										value="${bonus.advert.longitude}" placeholder="经度"
										readonly="readonly" id="longitude" name="longitude">
								</div>
								<div class="col-sm-2">
									<input type="text" class="form-control"
										value="${bonus.advert.latitude}" placeholder="纬度"
										readonly="readonly" id="latitude" name="latitude">
								</div>
								<div class="col-sm-1">
									<a href="javascript:;" class="btn btn-primary radius"
										onclick="getlnglat()">定位</a>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-1 control-label">范围</label>
								<div class="col-sm-2">
									<input type="text" class="form-control"
										value="${bonus.advert.distance_range}" placeholder=""
										id="distance_range" name="distance_range">
								</div>
								<div class="formControls col-1 mt-5">米</div>
							</div>
						</div>
					</div>

					<c:if test="${type!='3'}">
						<div class="form-group mt-10" style="display: none">
							<label class="col-sm-2 control-label">投放时间</label>
							<div class="col-sm-2">
								<input type="text" class="form-control"
									<c:if test="${!empty bonus}">disabled="disabled"</c:if>
									value="100" placeholder="" id="sign_term" name="sign_term">
								<!-- ${bonus.advert.sign_term} -->
							</div>
							<div class="col-sm-1">天</div>
						</div>
					</c:if>

					<c:if test="${type==2}">
						<div class="form-group">
							<label class="col-sm-2 control-label">年龄区间</label>
							<div class="col-sm-4">
								<span class="select-box"> <select name="age_range"
									class="form-control" datatype="*" nullmsg="请选择年龄段">
										<c:forEach items="${ageranges}" var="agerange">
											<option value="${agerange.id}"
												<c:if test="${bonus.advert.age_range == agerange.id}"> selected="selected"</c:if>>${agerange.display_name}</option>
										</c:forEach>
								</select>
								</span>
							</div>
						</div>

						<div class="form-group">
							<label class="col-sm-2 control-label">投放职业</label>
							<div class="col-sm-4">
								<span class="select-box"> <select name="job_title"
									class="form-control" datatype="*" nullmsg="请选择职业">
										<c:forEach items="${professions}" var="profession">
											<option value="${profession.item_value}"
												<c:if test="${bonus.advert.job_title==profession.item_value}"> selected="selected"</c:if>>${profession.display_name}</option>
										</c:forEach>
								</select></span>
							</div>
						</div>

						<div class="form-group">
							<label class="col-sm-2 control-label">兴趣爱好</label>
							<div class="col-sm-8">
								<div style="line-height: 35px;">
									<c:forEach items="${alllabels}" var="label">
										${label.label_name}:
										<c:forEach items="${label.childLabel}" var="clabel">
											<input type="checkbox" name="label"
												<c:if test="${fn:contains(bonus.advert.interest_key,clabel.label_name)}">checked="checked"</c:if>
												value="${clabel.label_name}">&nbsp;&nbsp;${clabel.label_name}&nbsp;&nbsp;&nbsp;&nbsp;
										</c:forEach>
										<br />
									</c:forEach>
								</div>
							</div>
						</div>
					</c:if>


					<div class="form-group">
						<label class="col-sm-2 control-label">平台收费标准</label>
						<div class="col-sm-3">
							<input type="text" readonly="readonly"
								class="form-control input-readyonly" value="0.3" placeholder=""
								id="oneclickprice">
						</div>
						<div class="col-sm-1">元/次</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">投放总金额</label>
						<div class="col-sm-4">
							<input type="text" class="form-control"
								<c:if test="${!empty bonus}">disabled="disabled"</c:if>
								value="${bonus.advert.total_amount}" placeholder=""
								id="total_amount" name="total_amount">
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">实际点击次数</label>
						<div class="col-sm-3">
							<input type="text" class="form-control input-readyonly"
								readonly="readonly" value="${bonus.count_charge}"
								<c:if test="${!empty bonus}">disabled="disabled"</c:if>
								placeholder="" id="clickcount" name="count_charge">
						</div>
						<div class="col-sm-1">次</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">广告曝光次数</label>
						<div class="col-sm-3">
							<input type="text" class="form-control input-readyonly"
								<c:if test="${!empty bonus}">disabled="disabled"</c:if>
								readonly="readonly" value="${bonus.count}" placeholder=""
								id="count" name="count">
						</div>
						<div class="col-sm-1">次</div>
					</div>
				</div>

				<!--  -->
				<div class="ibox-content2">
					<div class="ibox-title2">
						<h5>广告内容</h5>
					</div>
				</div>

				<div class="ibox-content">

					<div class="form-group">
						<label class="col-sm-2 control-label">广告标题</label>
						<div class="col-sm-6">
							<input type="text" class="form-control"
								value="${bonus.advert.adv_name}" placeholder="" id=""
								name="adv_name" datatype="*" nullmsg="不能为空">
						</div>
					</div>
					<!-- 图片类型的红包广告 -->
					<c:if test="${empty bonus || bonus.advert.resource_type==0}">
						<div id="imgresources" class="form-group" style="display: block;"
							<c:choose>
								<c:when test="${!empty bonus and bonus.advert.resource_type==1}"> style="display:none;"</c:when>
								<c:otherwise> style="display:block;"</c:otherwise></c:choose>>
							<div class="form-group">
								<label class="col-sm-2 control-label">缩略图</label>
								<div class="col-sm-10">

									<div class="col-sm-2">
										<a id="filePicker_covers"><i class="iconfont icon-plus1"></i></a>
										<br />尺寸：380px *380px<br />格式：JPG
									</div>

									<div id="fileList_covers" class="m-l-n uploader-list">
										<c:if test="${!empty bonus.advert.covers}">
											<div class="file-item thumbnail upload-state-done">
												<img src="${bonus.advert.covers}" />
												<div class="info"></div>
											</div>
										</c:if>
									</div>

									<input type="hidden" class="form-control"
										value="${bonus.advert.covers}" placeholder="" id="covers"
										name="covers">
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-2 control-label">轮播图</label>
								<div class="col-sm-10">

									<div class="col-sm-2">
										<a id="filePicker_resources"><i
											class="iconfont icon-plus1"></i></a> <br />尺寸： 380px *380px<br />格式：JPG
										数量：3张
									</div>

									<div id="fileList_resources" class="m-l-n uploader-list">
										<c:if test="${fn:length(bonus.advert.advert_resources)>0}">
											<c:forEach items="${bonus.advert.advert_resources}"
												var="resource">
												<div class="file-item thumbnail upload-state-done">
													<a onclick="delpic(this)">删除</a> <img
														src="${resource.resource_url}" />
													<div class="info">
														<input type="hidden" value="${resource.resource_url}"
															name="resources" />
													</div>
												</div>
											</c:forEach>
										</c:if>
									</div>

								</div>
							</div>
						</div>
					</c:if>

					<!-- 视频类型的红包广告 -->
					<c:if test="${empty bonus || bonus.advert.resource_type==1}">
						<div id="videourl" class="form-group" style="display: block;">
							<label class="col-sm-2 control-label">视频</label>
							<div class="col-sm-10">

								<div class="col-sm-2 m-l-n">
									<a id="filePicker_video"><i class="iconfont icon-plus1"></i></a>
									<br />播放时间：小于等于15秒<br />格式：mp4 avi
								</div>

								<div id="fileList_video" class="col-sm-2 uploader-list">
									<c:if test="${bonus.advert.resource_type==1}">
										<c:if test="${fn:length(bonus.advert.advert_resources)>0}">
											<c:forEach items="${bonus.advert.advert_resources}"
												var="resource">
												<div class="file-item">
													<img src="${bonus.advert.covers}?vframe/png/offset/3/" />
													<div class="info"></div>
												</div>
											</c:forEach>
										</c:if>
									</c:if>
								</div>

								<input type="hidden" class="form-control"
									value="${bonus.advert.resource_type==1?bonus.advert.covers:''}"
									placeholder="" id="video" name="videoresource">
							</div>
						</div>
					</c:if>

					<div class="form-group">
						<label class="col-sm-2 control-label">祝福语</label>
						<div class="col-sm-6">
							<input type="text" class="form-control"
								value="${bonus.bless_word}" placeholder=" 至少10个字以上" id=""
								name="bless_word">
						</div>
					</div>

					<div class="form-group">
						<div class="col-sm-4 col-sm-offset-2">
							<button class="btn btn-primary col-sm-4" type="button"
								onclick="save()">保存</button>
							&nbsp;&nbsp;
							<button class="btn btn-white" type="button" onclick="cancel()">取消</button>
						</div>
					</div>

				</div>

			</form>

		</div>
		<!-- /ibox -->
	</div>

	<script src="${ctx}/static/js/jquery.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/bootstrap.min.js?v=${static_version}"></script>
	<script
		src="${ctx}/static/js/plugins/footable/footable.all.min.js?v=${static_version}"></script>
	<script
		src="${ctx}/static/js/plugins/validate/jquery.validate.min.js?v=${static_version}"></script>
	<script
		src="${ctx}/static/js/plugins/validate/messages_zh.min.js?v=${static_version}"></script>
	<script
		src="${ctx}/static/js/plugins/webuploader/webuploader.min.js?v=${static_version}"></script>
	<script
		src="${ctx}/static/js/plugins/summernote/summernote.min.js?v=${static_version}"></script>
	<script
		src="${ctx}/static/js/plugins/summernote/summernote-zh-CN.js?v=${static_version}"></script>
	<script
		src="${ctx}/static/js/plugins/chosen/chosen.jquery.js?v=${static_version}"></script>
	<script
		src="${ctx}/static/js/plugins/iCheck/icheck.min.js?v=${static_version}"></script>
	<script
		src="${ctx}/static/plugins/laypage/laypage.js?v=${static_version}"></script>
	<script
		src="${ctx}/static/js/plugins/switchery/switchery.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/eModal.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/cookie.js?v=?v=${static_version}"></script>
	<script
		src="${ctx}/static/common/custom-datatable.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/content.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/common/common.js?v=${static_version}"></script>
	<script
		src="${ctx}/static/js/plugins/layer/laydate/laydate.js?v=${static_version}"></script>
	<script
		src="${ctx}/static/js/plugins/uploadify/jquery.uploadify.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/content.min.js?v=${static_version}"></script>
	<script
		src="${ctx}/static/js/plugins/layer/layer.js?v=${static_version}"></script>
	<!-- 地区控件资源 -->
	<script type="text/javascript"
		src="${ctx}/static/plugins/region/js/city-picker.data.js"></script>
	<script type="text/javascript"
		src="${ctx}/static/plugins/region/js/city-picker.js"></script>
	<script type="text/javascript"
		src="${ctx}/static/plugins/region/js/main.js"></script>
	<script
		src="${ctx}/static/js/plugins/datapicker/bootstrap-datepicker.js"></script>
	<script type="text/javascript"
		src="${ctx}/static/plugins/webuploader/0.1.5/webuploader.min.js"></script>
	<!-- 富文本编辑器资源 -->
	<script src="${ctx}/static/js/content.min.js?v=1.0.0"></script>
	<script src="${ctx}/static/js/plugins/summernote/summernote.min.js"></script>
	<script src="${ctx}/static/js/plugins/summernote/summernote-zh-CN.js"></script>
	<script src="${ctx}/static/js/pingpp.js"></script>
	<script src="${ctx}/static/js/uthinkjs/bonus.js?v=2.6"></script>
</html>